import { customRef } from "vue";
import { type App } from "vue";
const useLoadCount = (app: App): void => {
    const loadCount = customRef((track, trigger) => {
        let value = 0;
        return {
            get() {
                track();
                return value > 0;
            },
            set(newValue) {
                if (newValue) {
                    value++;
                } else {
                    value--;
                    value = Math.max(0, value);// 限制最小值为0
                }
                trigger();
            },
        };
    })
    app.config.globalProperties.$isLoading = loadCount;
    window.$isLoading = loadCount;
}
export default useLoadCount;